﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Data;
using System.IO;
using System.Linq;

using Cinch;
using MEFedMVVM.ViewModelLocator;
using MEFedMVVM.Services.Contracts;
using MEFedMVVM.Common;


namespace Anata.Client
{
    /// <summary>
    /// </summary>
    public class ProdukCabangFilterViewModel : ViewModelBase
    {
        #region Data
        #region Data.Primitives
        private DispatcherNotifiedObservableCollection<ProdukCabangViewModel> produkCabangs;
        private ICollectionView produkCabangsCV;
        #endregion

        #region Data.Rules
        #endregion

        #region Data.VMs
        #endregion

        #region Data.Services
        private IMessageBoxService messageBoxService;
        private IUIVisualizerService uiVisualizerService;
        #endregion
        #endregion

        #region Ctor
        [ImportingConstructor]
        public ProdukCabangFilterViewModel(
            IMessageBoxService messageBoxService,
            IUIVisualizerService uiVisualizerService)
        {
            #region Constructor.SetupServices
            this.messageBoxService = messageBoxService;
            this.uiVisualizerService = uiVisualizerService;
            //this.viewAwareStatusService = viewAwareStatusService;
            //this.viewAwareStatusService.ViewLoaded += ViewAwareStatusService_ViewLoaded;
            #endregion

            #region Constructor.SetupCommands
            ProdukCabangSelectCommand = new SimpleCommand<Object, Object>(CanExecuteProdukCabangSelectCommand, ExecuteProdukCabangSelectCommand);
            #endregion

            #region Constructor.CreateDataWrappers
            #endregion

            #region Constructor.CreateValidationRules
            #endregion

            #region Constructor.SetupCollections
            ProdukCabangs = new DispatcherNotifiedObservableCollection<ProdukCabangViewModel>();
            ProdukCabangsCV = CollectionViewSource.GetDefaultView(produkCabangs);
            #endregion

            //debug use
            ProdukCabangViewModel pcvm = null;
            for (int i = 1; i < 11; i++)
            {
                pcvm = new ProdukCabangViewModel(
                    messageBoxService,
                    uiVisualizerService);
                pcvm.IdJenisStok.DataValue = i;
                pcvm.NamaJenisStok.DataValue = "produk " + i;
                pcvm.IdCabang.DataValue = 1;
                pcvm.Harga.DataValue = i * 500;
                ProdukCabangs.Add(pcvm);
            }
            //LoadedKonsumenCV = CollectionViewSource.GetDefaultView(loadedKonsumen);
            //debug use

            //commands, SimpleCommand<T1,T2> T1 is CanExecute parameter type, and T2 is Execute type
        }
        #endregion

        #region Public Properties
        #region Public.Commands
        public SimpleCommand<Object, Object> ProdukCabangSelectCommand { get; set; }
        #endregion

        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs produkCabangsChangeArgs =
            ObservableHelper.CreateArgs<ProdukCabangFilterViewModel>(x => x.ProdukCabangs);
        public DispatcherNotifiedObservableCollection<ProdukCabangViewModel> ProdukCabangs
        {
            get { return produkCabangs; }
            set
            {
                produkCabangs = value;
                NotifyPropertyChanged(produkCabangsChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs produkCabangsCVChangeArgs =
            ObservableHelper.CreateArgs<ProdukCabangFilterViewModel>(x => x.ProdukCabangsCV);
        public ICollectionView ProdukCabangsCV
        {
            get { return produkCabangsCV; }
            set
            {
                produkCabangsCV = value;
                NotifyPropertyChanged(produkCabangsCVChangeArgs);
            }
        }
        #endregion

        #region Command Handlers
        private bool CanExecuteProdukCabangSelectCommand(Object args)
        {
            return true;
        }
        /// <summary>
        /// </summary>
        private void ExecuteProdukCabangSelectCommand(Object args)
        {
        }

        #endregion

        #region Private Methods
        //private void ViewAwareStatusService_ViewLoaded()
        //{
        //    konsumens = new DispatcherNotifiedObservableCollection<KonsumenViewModel>();
        //    KonsumenViewModel kvm = null;
        //    for (int i = 0; i < 10; i++)
        //    {
        //        kvm = new KonsumenViewModel();
        //        kvm.IdKonsumen.DataValue = i;
        //        kvm.Nama.DataValue = "Konsumen " + i;
        //        kvm.Alamat.DataValue = "Alamat " + i;
        //        konsumens.Add(new KonsumenViewModel());
        //    }
        //    //LoadedKonsumenCV = CollectionViewSource.GetDefaultView(loadedKonsumen);
        //}
        #endregion
    }

}
